<?php
require('lib/verify.php');
require('lib/has_char.php');
require('lib/is_approved.php');

$_category = "warmath";
$_title = "Schedule";
require('lib/head.php');

$system_id = $system["system_id"];

//$sql = "select *, wm_instances.instance_name from wm_raids left join wm_instances on wm_raids.raid_instance = wm_instances.instance_id where wm_raids.raid_system_id = $system_id order by raid_date desc";
//$result = $db->query($sql);

$ttime = time()-60*60*72;

$sql = "select *, wm_instances.* from wm_scheduled_raids left join wm_instances on wm_instances.instance_id = wm_scheduled_raids.scheduled_raid_instance where scheduled_raid_system_id='$system_id' and scheduled_raid_datetime > FROM_UNIXTIME($ttime) order by scheduled_raid_datetime desc";

$result = $db->query($sql);

//echo $sql;

boxTop("Warmath: $_title");

?>

<b>Upcoming Raids</b><br />
<br />
<?php
   if($character["character_admin"]) {
     ?>
     (<?adminfeature()?> <a href="schedule-raid.php">schedule a raid</a>)<br /><br />
<?php
   }
?>
<?php
while($sraid = $db->fetch_assoc($result)) {
?>
<a href="signup.php?id=<?=$sraid["scheduled_raid_id"]?>"><?=$sraid["instance_name"]?></b>, <b><?=date("D d M Y g:i a", strtotime($sraid["scheduled_raid_datetime"]))?></b></a><br />

<?php
$sql = "select *, wm_bosses.* from wm_scheduled_raid_bosses left join wm_bosses on wm_bosses.boss_id = wm_scheduled_raid_bosses.scheduled_raid_boss where scheduled_raid = '" . $sraid["scheduled_raid_id"] . "'";
$rez = $db->query($sql);
while($abo = $db->fetch_assoc($rez)) {
?>
<a href="boss.php?id=<?=$abo["boss_id"]?>"><?=$abo["boss_name_short"]?></a> 
<?php
}
?><br />

<i><?=$sraid["scheduled_raid_comments"]?></i><br />
<br />
<?php
   }
?>
<?php
boxBot();
?>

<?php
require('lib/foot.php');
?>

